<include file="header" />
<body>
<div class="wraper">
    <div class="load">
        <img class="load-bee" src="/assets/irs/images/load-bee.png"/>
    </div>
    <div class="top">
        <p><span class="iconfont icon-dingcanguanli"></span>{BEESCRM:$title}</p>
    </div>
	<volist name="data.list" id="vo">
		<div class="lists tb-mode">
			<a href="javascript:void(0)" class="tb-cell list-left">
				<div class="img-box"><img src="{BEESCRM:$vo.restaurant_img}"></div>
			</a>
			<div href="javascript:void(0)" class="tb-cell list-center">
				<p class="text-16">{BEESCRM:$vo.restaurant_name}<!--(当日须提前{BEESCRM:$vo.advance_time}分钟预定)--></p>
				<!--<p class="star-box">
					<span class="stars">
						<span>口味</span>
						<for start="0" end="$vo.taste"><span class="iconfont icon-xingxing star"></span></for>
						<for start="0" end="$vo.taste_star"><span class="iconfont icon-xingxing star grey-star"></span></for>
					</span>
				</p>
				<p class="star-box">
					<span class="stars">
						<span>质量</span>
						<for start="0" end="$vo.quality"><span class="iconfont icon-xingxing star"></span></for>
						<for start="0" end="$vo.quality_star"><span class="iconfont icon-xingxing star grey-star"></span></for>
					</span>
				</p>-->
				<p class="star-box">
					<span class="stars">
						<for start="0" end="$vo.quality"><span class="iconfont icon-xingxing star"></span></for>
						<for start="0" end="$vo.quality_star"><span class="iconfont icon-xingxing star grey-star"></span></for>
						<span>0分</span>
					</span>
				</p>
				<p class="text-12 text-deepgray">食堂二楼 | 提前20分钟预订 | 可外送</p>
			</div>
			<input type="hidden" value="{BEESCRM:$Eat}" id="eatTime">
			<input class="restaurant_" value="" data-id="{BEESCRM:$vo.restaurant_id}" data-time="{BEESCRM:$vo.advance_time}"/>
		</div>
	</volist>
	<div class="fenye" style="text-align: center">{BEESCRM:$page}</div>
    <div class="btn-box">
        <a href="#" class="btn actived"><span class="iconfont icon-weiwaimai"></span> 预订餐</a>
        <a href="/Zyyirs/Irs/myorder/irs_id/{BEESCRM:$irs_id}" class="btn"><span class="iconfont icon-dingdan"></span> 我的订单</a>
    </div>

	<input id="irs_id" value="{BEESCRM:$irs_id}" hidden/>
</div>

<include file="commonJS" />
<script src="/assets/public/mobiscroll/mobiscroll.custom-3.0.0-beta2.min.js"></script>
<script>
	$(function(){
		for(var i=0;i<$('.restaurant_').length;i++){
			var d = new Date();
			var time = $('.restaurant_').eq(i).data('time') + 1;
			var now = d.getHours()+':'+d.getMinutes();
			d.setMinutes(d.getMinutes()+time);
			var limitetime = d.getHours()+':'+d.getMinutes();

			var instance = mobiscroll.time($('.restaurant_').eq(i), {
				onBeforeShow: function (event, inst) {
					restaurant_id = $(this).data('id');
					if(eatTime == 1){
						location.href = '/Zyyirs/Irs/menu/restaurant_id/'+restaurant_id+'/irs_id/'+irs_id;
					}
				},
				theme: 'android-holo-light',
				lang: 'zh',
				display: 'center',
				headerText: false,
				maxWidth: 90,
				defaultValue: d,
				setText: '确认就餐时间',
				invalid: [
					{ start: now, end: limitetime }
				]
			});
		}

		$('.restaurant_').css({zIndex:9999});//把.restaurant的input提到最上层
		var restaurant_id = '';
		var irs_id = $('#irs_id').val();
		var eatTime = $("#eatTime").val();


		$('.restaurant_').change(function(){
			var eat = $(this).val();
			var info = {};
			var json = {};
			info.eat = eat;
			info.restaurant_id = restaurant_id;
			$.ajax({
				'url': "/Zyyirs/irs/setEatTime?irs_id="+irs_id,
				'data': info,
				'dataType':'json',
				'type': 'POST',
				'async': false,
				success: function(data) {
					if (data.status == 'S') {
						location.href = data.uri;
					}else{
						fm.alert(data.message);
						return false;
					}
				}
			});
		});
	})
</script>
</body>
</html>
